package com.threez.single.admin.singleadmin.config.exception;

import com.threez.single.admin.singleadmin.config.enums.BaseExceptionEnums;
import com.threez.single.admin.singleadmin.core.R;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

/**
 * 基础异常
 *
 * @author ruoyi
 */
@Data
@EqualsAndHashCode(callSuper = true)
@NoArgsConstructor
public class BaseException extends RuntimeException {
    private static final long serialVersionUID = 1L;


    /**
     * 错误码
     */
    private String code;

    /**
     * 错误码对应的参数
     */
    private Object data;

    /**
     * 错误消息
     */
    private String message;

    public BaseException(String code, Object data, String message) {
        this.code = code;
        this.data = data;
        this.message = message;
    }

    public BaseException(String message) {
        this(R.FAIL, null, message);
    }

    public BaseException(BaseExceptionEnums baseExceptionEnums) {
        this(baseExceptionEnums.getCode(), null, baseExceptionEnums.getMsg());
    }
}
